package com.tsai.wuxi.traffic.ui;

import java.util.List;

import com.tsai.wuxi.traffic.R;
import com.tsai.wuxi.traffic.model.Ticket;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class TicketAdapter extends BaseAdapter{

	private LayoutInflater mInflater;
	private Context mContext;
	private List<Ticket> mlist;
	
	public TicketAdapter(Context context,List<Ticket> list){
		this.mInflater = LayoutInflater.from(context);
		this.mContext = context;
		this.mlist = list;
	}
	
	@Override
	public int getCount() {
		return mlist.size();
	}

	@Override
	public Object getItem(int arg0) {
		return arg0;
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		convertView = mInflater.inflate(R.layout.ticket_search_result_item,null);
		TextView no=(TextView)convertView.findViewById(R.id.no);
		TextView datetime=(TextView)convertView.findViewById(R.id.datetime);
		TextView price=(TextView)convertView.findViewById(R.id.price);
		TextView ticket=(TextView)convertView.findViewById(R.id.tickets);
		
		no.setText(mlist.get(position).getNo());
		datetime.setText(mlist.get(position).getStartDatetime());
		price.setText(mlist.get(position).getPrice());
		ticket.setText(mlist.get(position).getTicket());
		
		return convertView;
	}

}
